import logging
import uvicorn

logging.basicConfig(level=logging.INFO) # 设定日志级别
logger = logging.getLogger(__file__) # 拿到当前文件的日志对象

# 定义 main
def main():
    """==应用程序启动入口=="""
    print("OrderSnap v1.0")
    # 启动应用 port是后端服务端口
    try:
        uvicorn.run(app="api.main:app", host="0.0.0.0", port=8000, reload=True, log_level="info")
    except KeyboardInterrupt as ke:
        logger.error(f"服务被中断,原因：{str(ke)}")
    except Exception as e:
        logger.error(f"服务启动失败,原因:{str(e)}")

# 调用 main
if __name__ == '__main__':
    main()